package com.zw.pdm.module.est.controller;

import com.zw.pdm.base.BaseController;
import com.zw.pdm.common.JsonResult;
import com.zw.pdm.entity.sys.User;
import com.zw.pdm.module.est.model.InputCostsModel;
import com.zw.pdm.module.est.model.SolderingCheckModel;
import com.zw.pdm.module.est.service.InputCostsService;
import com.zw.pdm.module.report.service.SheetService;
import com.zw.pdm.util.ShiroUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @Description: 控制层
 * @Author: China.kxx
 * @Date: 2020/11/04 20:33
 */
@Slf4j
@Controller
@RequestMapping("/est/dataEntry/solderingCheck")
public class CostsCheckController extends BaseController {


    //页面文件路径
    private String prefix = "/est/dataEntry";
    @Autowired
    private InputCostsService inputCostsService;
    @Autowired
    private SheetService sheetService;
    //加载页面
    @GetMapping("/page")
    public String solderingPlan(Model model) {
        return prefix + "/solderingCheck";
    }
//    @ResponseBody
    @GetMapping("/verify/{fkCode}/{partName}/{specialId}")
    public String solderingVerify(@PathVariable("fkCode") String fkCode,
                                  @PathVariable("partName") String partName,
                                  @PathVariable("specialId") Integer specialId,Model model) {
        model.addAttribute("project",inputCostsService.information(fkCode,partName,specialId));
        return "/est/dataEntry/solderingVerify";
    }
    /**
     * 加载审核列表数据
     * @param solderingCheckModel
     * @return
     */
    @ResponseBody
    @PostMapping("/list")
    public JsonResult list(SolderingCheckModel solderingCheckModel) {
        List<SolderingCheckModel> list = inputCostsService.solderingCheck(solderingCheckModel);
        return jsonResult(list);
    }

    /**
     * 加载工时列表数据
     * @param inputCostsModel
     * @return
     */
    @ResponseBody
    @PostMapping("/manpower")
    public JsonResult manpower(InputCostsModel inputCostsModel) {
        List<InputCostsModel> list = inputCostsService.solderManpower(inputCostsModel);
        return jsonResult(list);
    }
    /**
     * 加载辅材列表数据
     * @param inputCostsModel
     * @return
     */
    @ResponseBody
    @PostMapping("/material")
    public JsonResult material(InputCostsModel inputCostsModel) {
        List<InputCostsModel> list = inputCostsService.solderMaterialVerify(inputCostsModel);
        return jsonResult(list);
    }


}